package com.nciae.controller;


import com.nciae.po.Hoursemaster;
import com.nciae.po.Teacher;
import com.nciae.service.IHoursemasterService;
import com.nciae.service.IHousemasterSocreService;
import com.nciae.service.ITeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Guoliyu
 * @since 2022-03-31
 */
@RestController
@RequestMapping("/hoursemaster")
public class HoursemasterController {


    @Autowired
    private IHoursemasterService hoursemasterService;

    @GetMapping
    public ResponseEntity<List<Hoursemaster>> findAll(
            @RequestParam("username")String username
    ) {
        return ResponseEntity.ok(hoursemasterService.findAll(username));
    }

    @PostMapping
    public ResponseEntity<Boolean> add(@RequestBody Hoursemaster hoursemaster) {
        hoursemasterService.add(hoursemaster);
        return ResponseEntity.ok(true);
    }

    @PutMapping
    public ResponseEntity<Boolean> update(@RequestBody Hoursemaster hoursemaster) {
        hoursemasterService.update(hoursemaster);
        return ResponseEntity.ok(true);
    }

    @DeleteMapping("/{id}")
    public ResponseEntity<Boolean> delete(@PathVariable("id")Long id) {
        hoursemasterService.delete(id);
        return ResponseEntity.ok(true);
    }

}
